package com.itheima.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;

import javax.sql.DataSource;

@Configuration
public class TransactionConfig {
    /**
     *
     * @param dataSource
     * @return PlatformTransactionManager 返回值类型必须是PlatformTransactionManager 不然会报错
     */
    @Bean
    public PlatformTransactionManager dataSourceTransactionManager(@Autowired DataSource dataSource){
      return new DataSourceTransactionManager(dataSource);

    }

}
